<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Title</title>
</head>
<body>
	<button>计算</button>
	<button>假死现象</button>
	<button>在分线程中计算</button>
</body>
<script>
	const btns = document.querySelectorAll("button");
	btns[0].onclick = function(){
		console.log("开始计算！")
		let time = Date.now();
		let num = 0;
		for(let i=0;i<800000000;i++){
			num+=Math.random();
		}
		console.log("计算结束,结果："+num,"花费的时间："+(Date.now()-time));
	}
	btns[1].onclick = function(){
		console.log("假死现象");
	}
	btns[2].onclick = function(){
		if(window.Worker){
			const w = new Worker("./lib/my.js");
			w.postMessage(9000000);
		}else{
			alert("您当前的浏览器不支持Worker");
		}
	}
</script>
</html>